﻿<phone:PhoneApplicationPage 
    x:Class="DDU.Curriculum.Views.VacationsView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:UX="clr-namespace:DDU.UX;assembly=DDU.UX"
    xmlns:viewmodel="clr-namespace:DDU.ViewModel;assembly=DDU.ViewModel"
    xmlns:Converters="clr-namespace:DDU.Converters;assembly=DDU.Converters"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.IsVisible="False">

    <phone:PhoneApplicationPage.Resources>
        <Converters:EnumTranslateConverter x:Key="EnumTranslateConverter"/>
        <Converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    </phone:PhoneApplicationPage.Resources>
    <Grid x:Name="LayoutRoot">
        <Grid.Background>
            <ImageBrush Stretch="Fill" ImageSource="/Assets/back.png"/>
        </Grid.Background>
        <Grid.DataContext>
            <viewmodel:VacationsViewModel/>
        </Grid.DataContext>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition Height="auto"/>
        </Grid.RowDefinitions>
        
        <controls:Pivot Title="{StaticResource IDS_APP_NAME}">
            <!--<controls:Panorama.Title>
                <Image Source="{Binding LogoPath}" Margin="12,76,0,0"/>
            </controls:Panorama.Title>-->

            <!--
            <controls:PivotItem Header="{StaticResource IDS_VACATION_CUSTOMIZE}">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition Height="auto"/>
                    </Grid.RowDefinitions>
                    <ListBox ItemsSource="{Binding Path=ItemsOfVacations}" 
                             SelectedItem="{Binding Path=SelectedVacation, Mode=TwoWay}">
                        <ListBox.ItemContainerStyle>
                            <Style TargetType="ListBoxItem">
                                <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="ListBoxItem">
                                            <Grid>
                                                <Grid Background="White" Opacity="0"/>
                                                <StackPanel Margin="0,0,0,12">
                                                    <Grid>
                                                        <Grid.ColumnDefinitions>
                                                            <ColumnDefinition/>
                                                            <ColumnDefinition Width="auto"/>
                                                        </Grid.ColumnDefinitions>

                                                        <TextBlock Style="{StaticResource PhoneTextTitle2Style}" 
                                                                   Text="{Binding Title}"/>
                                                        <TextBlock Style="{StaticResource PhoneTextTitle2Style}" Grid.Column="1">
                                                            <Run Text="{Binding Duration}"/>
                                                            <Run Text=" "/>
                                                            <Run Text="{StaticResource IDS_COMMON_DAY}"/>
                                                        </TextBlock>
                                                    </Grid>
                                                    <TextBlock Style="{StaticResource PhoneTextSubtleStyle}" 
                                                               Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsSelected, Converter={StaticResource BooleanToVisibilityConverter}}">
                                                        <Run Text="{Binding StartTime,StringFormat=\{0:yyyy-MM-dd\}}"/>
                                                        <Run Text=" - "/>
                                                        <Run Text="{Binding EndTime,StringFormat=\{0:yyyy-MM-dd\}}"/>
                                                    </TextBlock>
                                                </StackPanel>
                                            </Grid>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </ListBox.ItemContainerStyle>
                    </ListBox>

                    

                    <Grid Grid.Row="1" Margin="12">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition/>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>

                        <UX:UXIconTextButton HorizontalAlignment="Center" 
                                             Content="删除" 
                                             Grid.Row="1" 
                                             Path="{StaticResource PATH_ICON_DELETE}" 
                                             Command="{Binding DeleteCommand, Mode=OneWay}"/>
                        <UX:UXIconTextButtonWithParam HorizontalAlignment="Center" 
                                                      Content="编辑" 
                                                      Path="{StaticResource PATH_ICON_EDIT}" 
                                                      Grid.Column="2" 
                                                      ParameterName="guid" 
                                                      ParameterValue="{Binding Path=SelectedVacation.Guid}" 
                                                      Uri="/Views/VacationEditView.xaml" />

                        <UX:UXPathButton Padding="13" Grid.Column="1"
                                         IconPath="{Binding Mode=OneWay, Source={StaticResource PATH_ICON_CLOSE}}" 
                                         Angle="45" 
                                         Uri="/Views/VacationAddView.xaml"/>
                    </Grid>
                </Grid>
            </controls:PivotItem>
            -->

            <controls:PivotItem Header="{StaticResource IDS_VACATION_STATUTORY}">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition Height="auto"/>
                    </Grid.RowDefinitions>
                    <ListBox ItemsSource="{Binding ItemsOfStatutotyVacations}">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <Grid Margin="12,0,0,12">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="96"/>
                                        <ColumnDefinition />
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition/>
                                        <RowDefinition/>
                                    </Grid.RowDefinitions>
                                    <Rectangle Fill="{StaticResource PhoneAccentBrush}" 
                                               HorizontalAlignment="Left" VerticalAlignment="Top" 
                                               Width="8" Height="32" 
                                               Grid.RowSpan="2" Margin="0,3,15,0"/>
                                    
                                    <TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" 
                                               Grid.Column="1" Grid.RowSpan="2" 
                                               Style="{StaticResource PhoneTextAccentStyle}">
                                        <Run Text="{Binding Path=Duration}"/>
                                        <Run Text=" "/>
                                        <Run Text="{StaticResource IDS_COMMON_DAY}"/>
                                    </TextBlock>
                                    <TextBlock Text="{Binding Path=Title}" 
                                               FontFamily="{StaticResource PhoneFontFamilySemiLight}" 
                                               Style="{StaticResource PhoneTextTitle3Style}"
                                               Grid.Column="2"/>
                                    <TextBlock Grid.Row="1" Style="{StaticResource PhoneTextSubtleStyle}"
                                               Foreground="{StaticResource PhoneChromeBrush}"
                                               Grid.Column="2">
                                        <Run Text="{Binding Path=Start,StringFormat=\{0:MM-dd\}}"/>
                                        <Run Text=" - "/>
                                        <Run Text="{Binding Path=End,StringFormat=\{0:MM-dd\}}"/>
                                    </TextBlock>
                                </Grid>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>

                    
                </Grid>
            </controls:PivotItem>

            <controls:PivotItem Header="{StaticResource IDS_VACATION_FESTIVAL}" 
                                Visibility="{Binding Path=FeatureAvailable, Converter={StaticResource BooleanToVisibilityConverter}}">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition Height="auto"/>
                    </Grid.RowDefinitions>
                    <ListBox ItemsSource="{Binding Path=ItemsOfFestivals}">
                        <ListBox.ItemContainerStyle>
                            <Style TargetType="ListBoxItem">
                                <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="ListBoxItem">
                                            <StackPanel Margin="0,0,0,12">
                                                <Grid>
                                                    <Grid.ColumnDefinitions>
                                                        <ColumnDefinition/>
                                                        <ColumnDefinition Width="auto"/>
                                                    </Grid.ColumnDefinitions>
                                                    <TextBlock Text="{Binding Path=Title}" 
                                                               Style="{StaticResource PhoneTextTitle2Style}" />
                                                    <TextBlock Text="{Binding Path=Type}" 
                                                               Style="{StaticResource PhoneTextAccentStyle}"
                                                               Grid.Column="1"/>
                                                </Grid>
                                                <TextBlock Style="{StaticResource PhoneTextSubtleStyle}"
                                                           Foreground="{StaticResource PhoneChromeBrush}">
                                                    <Run Text="{Binding Day, Converter={StaticResource EnumTranslateConverter}, Mode=OneWay}"/>
                                                    <Run Text=" "/>
                                                    <Run Text="{Binding Date,StringFormat=\{0: yyyy-MM-dd\}}"/>
                                                </TextBlock>
                                            </StackPanel>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </ListBox.ItemContainerStyle>
                    </ListBox>
                </Grid>
            </controls:PivotItem>
        </controls:Pivot>

        <ProgressBar IsIndeterminate="True"
                     VerticalAlignment="Top" 
                     Visibility="{Binding IsBusy, Converter={StaticResource BooleanToVisibilityConverter}}"/>

        <UX:UXPathButton Padding="13" 
                         Margin="12"
                         Grid.Row="1"
                         Height="48" Width="48"
                         IconPath="{StaticResource PATH_ICON_REFRESH}" 
                         Command="{Binding Path=RefreshCommand}" />
    </Grid>

</phone:PhoneApplicationPage>